package marchenko.springdao;

import java.util.List;

import marchenko.springdao.domain.Book;
import marchenko.springdao.repository.book.BookRepository;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class App 
{
    @SuppressWarnings("resource")
	public static void main( String[] args )
    {
        System.out.println( "Hello SpringDAO" );
        ApplicationContext appCtx = 
                new ClassPathXmlApplicationContext("mainContext.xml");
        
        BookRepository repository = appCtx.getBean("bookRepository", BookRepository.class);
        List<Book> books = repository.findAll();
        for (Book b : books) {
            System.out.println(b);
        }
        
        Book firstBook = repository.find(1);
        System.out.println(firstBook);
    }
}
